package com.trs.publish;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.annotation.EnableScheduling;


@SpringBootApplication
@EnableScheduling
@EnableConfigurationProperties
@ServletComponentScan
@ImportResource(locations = { "classpath:config/druid-bean.xml"})
public class PublishManagerApplication {

	public static void main(String[] args) {
		SpringApplication.run(PublishManagerApplication.class, args);
	}
	
	 /**
     * 自定义异常页
     * java8是使用lambda表达式来简化实现的方式
     */
    @Bean
    public EmbeddedServletContainerCustomizer containerCustomalizer() {

       return (container -> {
            ErrorPage error403Page = new ErrorPage(HttpStatus.FORBIDDEN, "/403.html");
            ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
            ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
            container.addErrorPages(error403Page, error404Page, error500Page);
       });
    }

   
}
